﻿namespace LengthofLastWord
{
    public class Solution
    {
        public int LengthOfLastWord(string s)
        {
            if (string.IsNullOrWhiteSpace(s))
                return 0;
            s = s.Trim();
            int lastLength = 0;
            for (int i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] == ' ')
                    break;
                    
                lastLength++;
            }

            return lastLength;
        }
    }
}